package com.sys.goods.pojo;

import java.util.Date;
import java.util.Map;
import java.util.TreeMap;

import com.sys.common.pojo.BasePojo;

/**
 * ~POJO(Plain Object java Object:(JavaBean) 得一个属性 得提供读写器 得有一个无参的构造函数
 * 
 * ~类名和表名一样 ~属性名和列名一样 ~对象和表里面的记录一样 ~表中间的下划线去掉
 * 
 * ~列模式:alt + shift + a; ~属性:四类八种默认值是0,包装类型默认是null;
 * 	
 * @author 陈岩
 */
public class AGoods extends BasePojo<AGoods>
{
	private int id;
	private int cateId ; 
	private String title;
	private String name;
	private String brief;
	private double marketPrice ; 
	private double price;
	private int stockNum;
	private int saleNum;
	private String listImg;
	private byte dataType;
	private String content;
	private byte status;
	private Date createTime;
	private Date updateTime;
	private Date pubTime;

	/*--字符串表示--*/
	private String statusStr;
	private String dataTypeStr;
	
	/*--关联关系表示--*/
	private ACate cate ; 
	
	/* 存储所有状态的容器 */
	private Map<String, String> enumsMap = new TreeMap<String, String>();

	/**
	 * 获取此表相关的所有枚举值
	 * 
	 * @return 键为枚举的变量名+枚举的值; 值为枚举的名字 如:key:STATUS_ENABLE-1,值:启用
	 */
	public Map<String, String> getEnumsMap()
	{
		// 根据状态值获取字符串描述
		AGoodsEnum[] enums = AGoodsEnum.values();
		for (int i = 0; i < enums.length; i++)
		{
			AGoodsEnum enumTemp = enums[i];
			String key = enumTemp.toString();
			enumsMap.put(key + "-" + enumTemp.getStatus() + "", enumTemp.getName());
		}
		return enumsMap;
	}
	
	/**
	 * 获取此表相关的所有枚举值
	 * 
	 * @return 键为枚举的变量名+枚举的值; 值为枚举的名字 如:key:STATUS_ENABLE-1,值:启用
	 */
	public Map<String, String> getEnums()
	{
		// 根据状态值获取字符串描述
		AGoodsEnum[] enums = AGoodsEnum.values();
		for (int i = 0; i < enums.length; i++)
		{
			AGoodsEnum enumTemp = enums[i];
			enumsMap.put(enumTemp.toString(), enumTemp.getStatus() + "");
		}
		return enumsMap;
	}

	/**
	 * 获取状态的字符串描述
	 * 
	 * @return 此状态对应的字符串描述
	 */
	public String getStatusStr()
	{
		// 根据状态值获取字符串描述
		AGoodsEnum[] enums = AGoodsEnum.values();
		for (int i = 0; i < enums.length; i++)
		{
			AGoodsEnum enumTemp = enums[i];
			if (enumTemp.toString().startsWith("STATUS_"))
			{
				// 表示是状态的标识
				if (enumTemp.getStatus() == this.getStatus())
				{
					this.statusStr = enumTemp.getName();
					break;
				}
			}
		}
		return statusStr;
	}

	/**
	 * 获取状态的字符串描述
	 * 
	 * @return 此状态对应的字符串描述
	 */
	public String getDataTypeStr()
	{
		// 根据状态值获取字符串描述
		AGoodsEnum[] enums = AGoodsEnum.values();
		for (int i = 0; i < enums.length; i++)
		{
			AGoodsEnum enumTemp = enums[i];
			if (enumTemp.toString().startsWith("DATATYPE_"))
			{
				// 表示是状态的标识
				if (enumTemp.getStatus() == this.getDataType())
				{
					this.dataTypeStr = enumTemp.getName();
					break;
				}
			}
		}
		return dataTypeStr;
	}

	public int getId()
	{
		return id;
	}

	public void setId(int id)
	{
		this.id = id;
	}

	public String getTitle()
	{
		return title;
	}

	public void setTitle(String title)
	{
		this.title = title;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public String getBrief()
	{
		return brief;
	}

	public void setBrief(String brief)
	{
		this.brief = brief;
	}

	public double getPrice()
	{
		return price;
	}

	public void setPrice(double price)
	{
		this.price = price;
	}

	public int getStockNum()
	{
		return stockNum;
	}

	public void setStockNum(int stockNum)
	{
		this.stockNum = stockNum;
	}

	public int getSaleNum()
	{
		return saleNum;
	}

	public void setSaleNum(int saleNum)
	{
		this.saleNum = saleNum;
	}

	public String getListImg()
	{
		return listImg;
	}

	public void setListImg(String listImg)
	{
		this.listImg = listImg;
	}

	public byte getDataType()
	{
		return dataType;
	}

	public void setDataType(byte dataType)
	{
		this.dataType = dataType;
	}

	public String getContent()
	{
		return content;
	}

	public void setContent(String content)
	{
		this.content = content;
	}

	public byte getStatus()
	{
		return status;
	}

	public void setStatus(byte status)
	{
		this.status = status;
	}

	public Date getCreateTime()
	{
		return createTime;
	}

	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}

	public Date getUpdateTime()
	{
		return updateTime;
	}

	public void setUpdateTime(Date updateTime)
	{
		this.updateTime = updateTime;
	}

	public Date getPubTime()
	{
		return pubTime;
	}

	public void setPubTime(Date pubTime)
	{
		this.pubTime = pubTime;
	}

	public void setEnumsMap(Map<String, String> enumsMap)
	{
		this.enumsMap = enumsMap;
	}

	public int getCateId()
	{
		return cateId;
	}

	public void setCateId(int cateId)
	{
		this.cateId = cateId;
	}

	public ACate getCate()
	{
		return cate;
	}

	public void setCate(ACate cate)
	{
		this.cate = cate;
	}

	public double getMarketPrice()
	{
		return marketPrice;
	}

	public void setMarketPrice(double marketPrice)
	{
		this.marketPrice = marketPrice;
	}
}
